﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Security.Principal;

public partial class SiteMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

        Button1.CausesValidation = false;
        if (Session["role"] == "Employee")
        {
            Button1.Text = "Log Out";
            Button1.Visible = true;
            NavigationMenu.Items.Add(new MenuItem("Add Customer", "AddCustomer", "", "~/Employee/Customer/AddCustomer.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Show Customers", "EditCustomer", "", "~/Employee/Customer/EditCustomer.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Rent a Vehicle", "RentCar", "", "~/Employee/Rent/RentCar.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Vehicle Return", "CarReturn", "", "~/Employee/Rent/ReturnCar.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Generate Report", "GeneratedReport", "", "~/Employee/GenerateReport.aspx"));
            NavigationMenu.Items.Add(new MenuItem("ChangePassword", "ChangePassword", "", "~/Account/ChangePassword.aspx"));
        }
        else if (Session["role"] == "admin")
        {
            Button1.Text = "Log Out";
            Button1.Visible = true;
            NavigationMenu.Items.Add(new MenuItem("Add Employee", "AddEmployee", "", "~/Admin/Employee/AddEmployee.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Show Employee", "EditEmployee", "", "~/Admin/Employee/EditEmployee.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Add Car", "AddCar", "", "~/Admin/Car/AddCar.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Show Cars", "EditCar", "", "~/Admin/Car/EditCar.aspx"));
            NavigationMenu.Items.Add(new MenuItem("Change Password", "ChangePassword", "", "~/Admin/ChangePassword.aspx"));
        }
        else
        {
            NavigationMenu.Items.Add(new MenuItem("Employee Login", "EmployeeLogin", "", "~/Account/Login.aspx"));

            NavigationMenu.Items.Add(new MenuItem("Admin Login", "AdminLogin", "", "~/Admin/Login.aspx"));
        }
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Button1.Text.Equals("Login"))
        {
            Response.Redirect("~/Account/Login.aspx");
        }
        else
        {
            Session.RemoveAll();
            Button1.Text = "Login";
            Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            Response.Redirect("~/Default.aspx");
        }

    }
}
